<template>
  <!--约课的首页item -->
  <div class="c-ph24 c-pt40 c-pb30 c-bd-b1" v-if="themeName == 'mb5' && !isMicroPage">
    <div class="c-flex-row c-aligni-center">
      <span class="c-fs30">{{reservationTitles}}</span>
      <span class="c-fs18 c-fc-sgray c-pt4 c-ml16 c-w0 c-flex-grow1 c-mr16 c-text-ellipsis1">{{reservationDesc}}</span>
      <span class="c-fs20 c-fc-gray" @click="clickMoreReservation">更多</span>
    </div>
    <div class=" c-pt30 c-flex-row" @click="clickGoReservation(item.rtId)" v-for="(item,index) in reservationList" :key="index">
      <div class="c-ww240 c-maxh160 c-text-hidden c-br10">
        <img class="c-w100 imgCloseBig c-br10" :src="$addXossFilter(item.poster, require('../../assets/defult270.png'))" />
      </div>
      <div class="c-pl20 c-w0 c-flex-grow1 c-flex-column c-justify-sb">
        <div class="c-fs24 c-text-ellipsis2 c-lh32">{{item.themeName}}</div>
        <div class="c-pb10 c-flex-row c-aligni-center">
          <div class="theme-fc c-flex-row c-aligni-end c-flex-grow1 c-w0" :class="Number(item.price) == 0 ? 'c-fs22' : 'c-fs24'">
            <span v-if="Number(item.price) > 0">{{'￥' | iosPriceFilter}}</span>{{Number(item.price) | moneyStr}}
          </div>
          <div v-if="item.isShowOrder == 1" class="c-fs18 c-fc-gray">{{item.count}}人{{$isWxAppIos() ? '预约' : '购买'}}</div>
        </div>
      </div>
    </div>
  </div>
  <div v-else-if="(themeName == 'mb3' || themeName == 'mb4') && !isMicroPage">
    <index-three-title-com v-if="themeName == 'mb3'" :titleName="reservationTitles" :titleDesc="reservationDesc" @clickMore="clickMoreReservation"></index-three-title-com>
    <div v-else>
      <div class="c-ph24 c-pt40 c-flex-row c-aligni-center">
        <span class="c-fs30 c-p c-lh c-pl20"><span class="c-pa theme-bd-l2 theme-bd-r2 c-h c-p-l0 c-br8 c-w0"></span>{{reservationTitles}}</span>
        <span class="c-fs18 c-fc-sgray c-pt4 c-ml16 c-w0 c-flex-grow1 c-mr16 c-text-ellipsis1">{{reservationDesc}}</span>
        <span class="c-fc-gray c-pl8 c-fs20" @click="clickMoreReservation">查看更多</span>
      </div>
    </div>
    <div class="c-ph24 c-pb20 c-bd-b12-f5">
      <div class="c-flex-row c-pt24" v-for="(item,index) in reservationList" :key="index" @click="clickGoReservation(item.rtId)">
        <div class="c-pb24">
          <div class="c-ww210 c-maxh210 c-text-hidden c-p c-br10">
            <img class="c-w100 imgCloseBig" :class="(themeName == 'mb3' || themeName == 'mb4') ? 'c-br10' : ''" :src="$addXossFilter(item.poster, require('../../assets/defult270.png'))" />
          </div>
        </div>
        <div class="c-ml20 c-w0 c-flex-grow1 c-flex-column c-justify-sb c-pb24" :class="index == reservationList.length - 1 ? '' : 'c-bd-b1'">
          <div class="c-fs24 c-text-ellipsis2">{{item.themeName}}</div>
          <div class="c-flex-row c-aligni-center">
            <div class="theme-fc c-flex-row c-aligni-end c-flex-grow1 c-w0" :class="Number(item.price) == 0 ? 'c-fs22' : 'c-fs24'">
              <span v-if="Number(item.price) > 0">{{'￥' | iosPriceFilter}}</span>{{Number(item.price) | moneyStr}}
            </div>
            <div v-if="item.isShowOrder == 1" class="c-fs18 c-fc-gray">{{item.count}}人{{$isWxAppIos() ? '预约' : '购买'}}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="c-ph24 c-pt24 c-pb20 c-mt12 c-bg-white" v-else-if="themeName == 'mb6' && !isMicroPage">
    <div class="c-flex-row c-aligni-end">
      <span class="c-fs28 c-fw-b">{{reservationTitles}}</span>
      <span class="c-fs20 c-fc-gray c-mb2 c-ml16 c-w0 c-flex-grow1 c-mr16 c-text-ellipsis1">{{reservationDesc}}</span>
      <span class="c-fs18 c-fc-gray" @click="clickMoreReservation">更多约课</span>
    </div>
    <div class="c-pt24 c-flex-row" v-for="(item,index) in reservationList" :key="index" @click="clickGoReservation(item.rtId)">
      <div class="c-pb24">
        <div class="c-ww160 c-maxh106 c-text-hidden c-br10">
          <img class="c-w100 imgCloseBig c-br10" :src="$addXossFilter(item.poster, require('../../assets/defult270.png'))" />
        </div>
      </div>
      <div class="c-pl20 c-w0 c-flex-grow1 c-flex-column c-justify-sb c-pb24" :class="index == reservationList.length - 1 ? '' : 'c-bd-b1'">
        <div class="c-fs24 c-text-ellipsis2 c-fw-b c-lh36">{{item.themeName}}</div>
        <div class="c-flex-row c-aligni-end">
          <span class="c-flex-grow1 c-w0 theme-fc" :class="Number(item.price) == 0 ? 'c-fs22' : 'c-fs24'"><span v-if="Number(item.price) != 0">{{'￥' | iosPriceFilter}}</span>{{item.price | moneyStr}}</span>
          <div v-if="item.isShowOrder == 1" class="c-fs18 c-fc-gray ">{{item.count}}人{{$isWxAppIos() ? '预约' : '购买'}}</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import indexThreeTitleCom from "@/components/templates/common/indexThreeTitleCom.vue";
import { utilJs } from "@/utils/common.js"
export default {
  name: "ClockIndexCom",
  components: {
    indexThreeTitleCom
  },
  props: {
    reservationTitles: {
      type: String,
      default: '主题约课',
    },
    reservationDesc: {
      type: String,
      default: '一次购买，终身可约',
    },
    reservationList: {
      type: Array,
      default: () => []
    },
    isFromM7: {
      type: Boolean,
      default: false
    },
    isMicroPage: {
      type: Boolean,
      default: false
    },
    itemType: {
      type: Number,
      default: 1, //1一行一列，2一行两列，3一行三列
    },
    showCount: {
      type: Number,
      default: 1
    },
    showMore: {
      type: Number,
      default: 0,
    },
    visible:{
      type: Object,
      default: () => {
        return {
          priceVisible:true, // 价格、商品价格
          originalPriceVisible:true, // 划线价格
          dataVisible:true, // 商品数据、数据字段、数据
          statusVisible:true, // 状态
          forecastVisible:true, // 预告时间
          qrVisible:true, // 预告二维码
          vipVisible:true, // vip角标
        }
      },
    }
  },
  data() {
    return {
      theme: localStorage.getItem("colorName") ? localStorage.getItem("colorName") : "mb5_default",
      themeName: localStorage.getItem("themeName") ? localStorage.getItem("themeName") : "mb5"
    };
  },
  methods: {
    clickMore() {
      this.$emit('clickMore');
    },
    iosAppRouteChange(toPath) {
      if (utilJs.isIOSApp()) {
        window.webkit.messageHandlers.iosWechatRoute.postMessage(toPath);
      } else if (utilJs.isAndoridNewApp()) {
        let data = {
          path: toPath
        }
        window.androidWechatRoute.doAction(JSON.stringify(data))
      } else {
        this.$routerGo(this, "push", { path: toPath });
      }
    },
    clickMoreReservation() {
      let toPath = `/homePage/reservation/reservationList`;
      this.iosAppRouteChange(toPath);
    },
    clickGoReservation(rtId) {
      let toPath = `/activity/activityDetail?ActivityNo=${rtId}&from=reservation`;
      this.iosAppRouteChange(toPath);
    }
  }
};
</script>

<style scoped>
.mb4_default .theme-bd-r2 {
  border-right: 2px solid #ff300c;
}
</style>
